;;;
;;;10/4/2007 Added the command IDVIEWS to show the fixed view numbers specified
;;;by the CAD Layer Guidelines (CLG) layer name.  If the CLG minor group of the
;;;viewport layer name does not specify a viewport number in the form "VI##"
;;;the user is asked to specify a viewport number to assign to the viewport.
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe Street
;;;		Southern Pines, NC 28387
;;;
;;;	http://paracadd.com
;;;	All rights reserved.
;;;
;;;
(DEFUN C:VIEWNO (/ cvpss cvpent cvpename fixvpl viewno)
;;;  (IF (OR (NOT LAYOUTLIST) (IF LAYOUTLIST (=(LENGTH(LAYOUTLIST))1)))
  (vl-load-com)
  (PROGN (SETQ curvno (GETVAR "cvport"))
         (SETQ cvpss (SSGET "X" (LIST (CONS 410 (GETVAR "CTAB")) (CONS 69 curvno))))
         (SETQ cvpent (ENTGET (SSNAME cvpss 0)))
         (SETQ cvpename (CDR (ASSOC -1 cvpent)))
         (IF uint
           nil
           (LOAD "uint" "\nFile UINT.LSP not loaded! ")
         ) ;_ end of IF
         (IF ukword
           nil
           (LOAD "ukword" "\nFile UKWORD.LSP not loaded! ")
         ) ;_ end of IF
         (SETQ viewno (uint 1 "" "View number? " viewno))
         (IF (< viewno 10)
           (SETQ prod (STRCAT "VI0" (ITOA viewno)))
           (SETQ prod (STRCAT "VI" (ITOA viewno)))
         ) ;_ end of if
         (IF (WCMATCH (STRCASE (SUBSTR (GETVAR "dwgname") 1 1)) "[ACEFGILMOPQSTZ]")
           (SETQ vplmjr (STRCASE (SUBSTR (GETVAR "dwgname") 1 1)))
           (SETQ vplmjr "G")
         ) ;_ end of if
         (SETQ new_nplt_lay (STRCASE (STRCAT vplmjr "-" prod "7nplt")))
         (SETQ fixvpl (ukword 1 "Yes No" (STRCAT "Change viewport layer to " new_nplt_lay) (IF fixvpl fixvpl "Yes")))
         (IF (EQ fixvpl "Yes")
           (PROGN (COMMAND ".pspace")
                  (COMMAND "-layer" "m" new_nplt_lay "")
                  (IF (AND (ASSOC 340 cvpent) (ASSOC 8 (ENTGET (CDR (ASSOC 340 cvpent)))))
                    (PROGN (COMMAND ".chprop" (CDR (ASSOC 340 cvpent)) "" "la" new_nplt_lay ""))
                  ) ;_ end of IF
                  (COMMAND ".chprop" cvpename "" "la" new_nplt_lay "")
                  (vla-put-MSpace (vla-get-Activedocument (vlax-get-Acad-Object)) :vlax-true)
;;;                  (COMMAND ".mspace")
           ) ;_ end of progn
           (PROGN (SETQ change_mjrg (ukword 1 "A C E F G I L M O P Q S T Z None" "Select another CLG major group [A/C/E/F/G/I/L/M/O/P/Q/S/T/Z/None]" change_mjrg))
                  (IF (NOT (EQ change_mjrg "None"))
                    (PROGN
                      (SETQ new_nplt_lay (STRCASE (STRCAT change_mjrg "-" prod "7nplt")))
                      (SETQ fixvpl (ukword 1 "Yes No" (STRCAT "Change viewport layer to " new_nplt_lay) "Yes"))
                      (IF (EQ fixvpl "Yes")
                        (PROGN (COMMAND ".pspace")
                               (COMMAND "-layer" "m" new_nplt_lay "")
                               (IF (AND (ASSOC 340 cvpent) (ASSOC 8 (ENTGET (CDR (ASSOC 340 cvpent)))))
                                 (PROGN (COMMAND ".chprop" (CDR (ASSOC 340 cvpent)) "" "la" new_nplt_lay ""))
                               ) ;_ end of IF
                               (COMMAND ".chprop" cvpename "" "la" new_nplt_lay "")
                               (vla-put-MSpace (vla-get-Activedocument (vlax-get-Acad-Object)) :vlax-true)
;;;                               (COMMAND ".mspace")
                        ) ;_ end of progn
                      )
                    )
                  )
           )
         ) ;_ end of if
  ) ;_ end of PROGN
;;;    (PROGN (PRINC "\nMore than one layout present. Viewport layer checking aborted.")(PRINC))
;;;  ) ;_ end of IF
) ;_ end of DEFUN
(DEFUN C:IDVIEWS ()
  (vl-load-com)
  (IF gvpno NIL (LOAD "gvpno" "\nFile GVPNO.LSP not loaded! "))
  (SETQ IDVIEWS_TILEMODE (GETVAR "tilemode"))
  (IF (EQ (GETVAR "tilemode") 1)
    (SETVAR "tilemode" 0)
  ) ;_ end of IF
  (SETQ allvp_ss (SSGET "x" '((0 . "VIEWPORT"))))
  (SETQ allviewports (VPORTS))
  (vla-put-MSpace (vla-get-Activedocument (vlax-get-Acad-Object)) :vlax-true)
;;;  (COMMAND ".MSPACE")
  (FOREACH n allviewports
    (IF (EQ (CAR n) 1)
      NIL
      (PROGN (SETVAR "cvport" (CAR n))
             (gvpno)
             (COMMAND "vslide"
                      (STRCAT (IF (< viewno 10)
                                "view0"
                                "view"
                              ) ;_ end of if
                              (ITOA viewno)
                      ) ;_ end of strcat
             ) ;_ end of COMMAND
      ) ;_ end of PROGN
    ) ;_ end of IF
  ) ;_ end of FOREACH
  (COMMAND ".PSPACE")
  (COMMAND pause ".REDRAWALL")
  (PRINC)
) ;_ end of DEFUN
(DEFUN C:RDA () (COMMAND ".REDRAWALL") (PRINC))